package com.mocha.bss.config;

import com.coffee.log.capture.CoffeeOperationLogHandler;
import com.coffee.log.capture.OperationLogBO;
import com.coffee.log.dispose.OperationLogService;
import com.pinghua.mocha.basics.enumerate.MochaSocpEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author songkui
 * @since 2025/4/27
 */
@Slf4j
@AllArgsConstructor
@Component("bssOperationLogHandler")
public class BssOperationLogHandler implements CoffeeOperationLogHandler {

    private final OperationLogService operationLogService;
    @Override
    public void handler(OperationLogBO operationLogBO) {
        log.info("FwctOperationLogHandler handler operationLogBO:{}", operationLogBO);
        MochaSocpEnum socpEnum = MochaSocpEnum.ofCode(operationLogBO.getApp());
        if (socpEnum == null){
            socpEnum = MochaSocpEnum.PC;
            log.error("SmartOperationLogHandler handler operationLogBO:{}", operationLogBO);
        }
        operationLogBO.setTablePos(socpEnum.table());
        operationLogService.save(operationLogBO);
    }

}
